package com.example.douyin.zhibo;

import androidx.lifecycle.MutableLiveData;

import com.example.lib_base_mvvm.baseMVVM.BaseViewModel.BaseViewModel;
import com.example.lib_base_mvvm.entity.GiftEntity;
import com.example.lib_base_mvvm.entity.ResultEntity;
import com.example.lib_base_mvvm.utils.ConstantsUtils;
import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class ZhiboViewModel extends BaseViewModel<ZhiboRepo> {
    @Override
    protected ZhiboRepo createRepo() {
        return new ZhiboRepo();
    }

    public MutableLiveData<ResultEntity> guanzhuSuccess  = new MutableLiveData<>();
    public MutableLiveData<String> guanzhuFail = new MutableLiveData<>();

    public MutableLiveData<GiftEntity> giftSuccess = new MutableLiveData<>();
    public MutableLiveData<String> giftFail = new MutableLiveData<>();

    public void guanzhu(String authname){
        Map<String,String> map = new HashMap<>();
        map.put(ConstantsUtils.PARAM_AUTHNAME,authname);
        String s = new Gson().toJson(map);
        RequestBody body = RequestBody.create(MediaType.parse(ConstantsUtils.PARAM_TYPE_JSON),s);
        repo.guanzhu(body,guanzhuSuccess,guanzhuFail);
    }

    public void gift(){
        repo.gift(giftSuccess,giftFail);
    }
}
